CC=/usr/local/bin/arm-apple-darwin-gcc
CXX=/usr/local/bin/arm-apple-darwin-g++

LD=$(CC)
CFLAGS=-Isrc/ -DIPHONE
LDFLAGS =	-framework CoreFoundation \
			-framework Foundation \
			-framework UIKit \
			-framework LayerKit \
			-framework CoreGraphics \
			-framework GraphicsServices \
			-framework CoreSurface \
			-framework IOKit \
			-framework WebKit \
			-framework OfficeImport \
			-lobjc \
			-Wl,-macosx_version_min,10.5

COMMON_OBJECTS= src/Subject.o \
			src/SubjectsManager.o \
			src/Lesson.o \
			src/Mark.o \
			src/Pupil.o \
			src/XMLClass.o
			
IPHONE_OBJECTS= src/iPhone/main.o \
			src/iPhone/iMarks.o \
			src/iPhone/MarksView.o \
			src/iPhone/ViewManager.o \
			src/iPhone/SubjectView.o \
			src/iPhone/SubjectDetailView.o \
			src/iPhone/SubjectEditView.o \
			src/iPhone/SettingsView.o \
			src/iPhone/TimeTableView.o \
			src/iPhone/TimeTableDayView.o \
			src/iPhone/NewDeleteRefresh.o 

OBJECTS = $(COMMON_OBJECTS) $(IPHONE_OBJECTS)
			
			
DEBUG = -DDEBUG -Wall -g

all:	iMarks.app

iMarks.app: iMarks
	@(bash -c "echo -n \"Build $@...\"")
	@(mkdir -p iMarks.app)
	@(buildnummer Info_iPhone.plist)
	@(cp -rf *.lproj iMarks.app/) 
	@(cp Info_iPhone.plist iMarks.app/Info.plist)
	@(mv iMarks iMarks.app/)
	@(chmod -R a+x iMarks.app/)
	@(echo "done.")

iMarks:	$(OBJECTS)
	@(echo "Link $@")
	@($(LD) $(DEBUG) $(LDFLAGS) -o $@ $^ > /dev/null)

%.o:	%.m
		@(echo "Compile $@")
		@($(CC) $(DEBUG) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ > /dev/null)

install: iMarks.app
	@(scp -o BindAddress=192.168.2.25 -r iMarks.app/ root@192.168.2.26:/Applications)

clean:
		@(rm -rf src/*.o iMarks.app/* src/iPhone/*.o)

